home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-05 / netpq.zip / SHOWDATA.C < prev    next >
Text File  |  1992-02-24  |  6KB  |  280 lines

  1. #include <stdio.h>
  2. #include <conio.h>
  3.  
  4. #include "nos.h"
  5. #include "noslib.h"
  6. #include "netpq.h"
  7.  
  8. extern struct serverdef *server;
  9. extern struct localqueuedef *localqueue;
  10.  
  11. extern int currentserver, adaptornum, numberoflogins, currentprinter, found;
  12. extern int queuejobcount, printjobcount;
  13. extern int maxlocalqueuecount, localqueuecount;
  14.  
  15. char *statusstring [] =
  16.     {
  17.     "FREE",
  18.     "UPDATING",
  19.     "HOLDING",
  20.     "WAITING",
  21.     "DESPOOLING",
  22.     "CANCELLED",
  23.     "FILE ERROR",
  24.     "SPOOL ERROR",
  25.     "* RUSH *"
  26.     };
  27.  
  28. int numberofprinterstrings = 6;
  29. char *printerstring [] =
  30.     {
  31.     "LPT1:",
  32.     "LPT2:",
  33.     "LPT3:",
  34.     "COM1:",
  35.     "COM2:",
  36.     "ALL"
  37.     };
  38.  
  39. char *printerstatusstring [] =
  40.     {
  41.     "Disabled",
  42.     "Single",
  43.     "Enabled"
  44.     };
  45.  
  46.  
  47.  
  48. reportinfo ()
  49. {
  50. //report server name & time
  51.  
  52.     currentserver = 0;
  53.     while (currentserver < numberoflogins)
  54.     {
  55.     highvideo ();
  56.     textcolor (YELLOW);
  57.     cprintf ("%-15s", server [currentserver] .servername);
  58.     nohighlight ();
  59.     cprintf ("%*s%02d/%02d/%04d %02d:%02d:%02d", 42,"",
  60.         server [currentserver] .time.TB_month,
  61.         server [currentserver] .time.TB_day,
  62.         server [currentserver] .time.TB_year,
  63.         server [currentserver] .time.TB_hour,
  64.         server [currentserver] .time.TB_minutes,
  65.         server [currentserver] .time.TB_seconds);
  66.     cprintf ("\r\n");
  67.  
  68.     reportprinterstatus ();
  69.  
  70.     reportprinterjobs ();
  71.  
  72.     currentserver++;
  73.     }
  74. }
  75.  
  76.  
  77.  
  78. reportprinterstatus ()
  79. {
  80. //  report status of each of the 5 printer ports on the server
  81.  
  82.     currentprinter = 0;
  83.     while (currentprinter < 5)
  84.     {
  85.     if (server [currentserver] .PS_state_value [currentprinter] != 0)
  86.         {
  87.         highlight ();
  88.         cprintf ("%s ", printerstring [currentprinter]);
  89.  
  90.         if (server [currentserver] .PS_state_pause [currentprinter] == 1)
  91.         {
  92.         highlightblink ();
  93.         cprintf ("%-10s", "Paused");
  94.         }
  95.         else
  96.         {
  97.         if (server [currentserver] .PS_index [currentprinter] < 65535)
  98.             {
  99.             if (server [currentserver] .PS_CPS [currentprinter] == 0)
  100.             highlightblink ();
  101.             cprintf ("%4d CPS  ", server [currentserver] .PS_CPS [currentprinter]);
  102.             }
  103.         else
  104.             cprintf ("%-10s", printerstatusstring [server [currentserver] .PS_state_value [currentprinter] ]);
  105.         }
  106.         nohighlight ();
  107.         }
  108.     else
  109.         {
  110.         cprintf ("%s ", printerstring [currentprinter]);
  111.         cprintf ("Disabled  ");
  112.         }
  113.     currentprinter++;
  114.     }
  115.     cprintf ("\r\n");
  116. }
  117.  
  118.  
  119.  
  120. reportprinterjobs ()
  121. {
  122. //report status of each printer job in the server's queue
  123.  
  124. int outputjobcount;
  125.  
  126.     printjobcount = 0;
  127.     outputjobcount = 0;
  128.     found = false;
  129.  
  130.     while (printjobcount < localqueuecount)
  131.     {
  132.     if (localqueue [printjobcount] .server == currentserver)
  133.         {
  134.         if (found == false)
  135.         {
  136.         textcolor (CYAN);
  137.         cprintf ("%-6s %-12s %-12s %-12s %-12s %11s %8s",
  138.             "SEQ #", "USER NAME", "MACHINE", "COMMENT",
  139.             "DESTINATION", "STATUS", "SIZE");
  140.         cprintf ("\r\n");
  141.         found = true;
  142.         }
  143.  
  144.         choosecolor (localqueue [printjobcount] .QE_status);
  145.         localqueue [printjobcount] .QE_user [12] = '\0';
  146.         localqueue [printjobcount] .QE_machine [12] = '\0';
  147.         localqueue [printjobcount] .QE_comment [12] = '\0';
  148.         localqueue [printjobcount] .QE_destination [12] = '\0';
  149.  
  150.         cprintf ("%-6lu", localqueue [printjobcount] .QE_sequence);
  151.         cprintf (" %-12s", localqueue [printjobcount] .QE_user);
  152.         cprintf (" %-12s", localqueue [printjobcount] .QE_machine);
  153.         cprintf (" %-12s", localqueue [printjobcount] .QE_comment);
  154.         cprintf (" %-12s", localqueue [printjobcount] .QE_destination);
  155.  
  156.         //    If despooling, display number of bytes sent
  157.  
  158.         if ( (localqueue [printjobcount] .QE_status == 4) && (localqueue [printjobcount] .printer != -1) )
  159.         {
  160.         cprintf (" %8lu of", server [currentserver] .PS_output_chars [localqueue [printjobcount] .printer]);
  161.         }
  162.         else
  163.         cprintf (" %11s", statusstring [localqueue [printjobcount] .QE_status] );
  164.  
  165.         cprintf (" %8lu", localqueue [printjobcount] .QE_size);
  166.         cprintf ("\r\n");
  167.         outputjobcount++;
  168.         if ( (localqueuecount > (21 - (numberoflogins * 5))) &&
  169.         (outputjobcount > (21 - (numberoflogins * 5)) / numberoflogins))
  170.         {
  171.         errorhighlight ();
  172.         cprintf ("Total of %d files in queue\r\n", server [currentserver] .queue_jobs);
  173.         printjobcount = localqueuecount;
  174.         }
  175.         nohighlight ();
  176.         }
  177.     printjobcount++;
  178.     }
  179.  
  180.     if (found == false)
  181.     {
  182.     cprintf ("No files spooled");
  183.     cprintf ("\r\n");
  184.     }
  185.     cprintf ("\r\n");
  186. }
  187.  
  188.  
  189. getextch ()
  190. {
  191. //  gets value of extended key press
  192.  
  193. int c;
  194.     c = getch ();
  195.     if (c == 0)
  196.     {
  197.     c = getch ();
  198.     if (c < 128)
  199.         c += 128;
  200.     }
  201.     return (c);
  202. }
  203.  
  204.  
  205. highlight ()
  206. {
  207. //  sets colors for active servers, and ports
  208.  
  209.     textcolor (YELLOW);
  210.     highvideo ();
  211. }
  212.  
  213.  
  214. nohighlight ()
  215. {
  216. //  sets colors for server time & inactive ports
  217.  
  218.     textcolor (CYAN);
  219.     lowvideo ();
  220. }
  221.  
  222.  
  223. highlightblink ()
  224. {
  225. //  sets colors for paused and 0 CPS ports
  226.  
  227.     textcolor (LIGHTRED + BLINK);
  228.     highvideo ();
  229. }
  230.  
  231. errorhighlight ()
  232. {
  233. //  sets colors for error messages
  234.  
  235.     textcolor (LIGHTRED);
  236.     highvideo ();
  237. }
  238.  
  239. choosecolor (int status)
  240. {
  241. //  sets colors for queued files status
  242.  
  243.     switch (status)
  244.     {
  245.     case 2:
  246.         textcolor (RED);
  247.         break;
  248.     case 3:
  249.     case 8:
  250.         textcolor (GREEN);
  251.         break;
  252.     case 4:
  253.         textcolor (YELLOW);
  254.         highvideo ();
  255.         break;
  256.     default:
  257.         textcolor (CYAN);
  258.         break;
  259.     }
  260. }
  261.  
  262.  
  263.  
  264. message (char *messagetext, int eraseflag)
  265. {
  266. //  displays message in center of the first line of the screen
  267.  
  268.     gotoxy ( (40 - (strlen (messagetext) / 2) ), 1);
  269.     errorhighlight ();
  270.     cprintf ("%s", messagetext);
  271.     nohighlight ();
  272.  
  273.     if (eraseflag == true)
  274.     {
  275.     sleep (2);
  276.     gotoxy ( (40 - (strlen (messagetext) / 2) ), 1);
  277.     cprintf ("%*s", strlen (messagetext), " ");
  278.     }
  279. }
  280.